﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
    CodeBehind="DBMaintain.aspx.cs" Inherits="LightWeb.Blog.Admin.DBMaintain" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    LightWeb Blog Dashboard - Database Maintain
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <button id="btnReCreateDbSchema" value="">
        ReCreate Database Schema
    </button>
    <button id="btnInsertData" value="">
        Insert Test Data</button>
    <div id="msg">
    </div>
    <script type="text/javascript">
        $(function () {
            $("#btnReCreateDbSchema").click(function () {
                //                var odata = GetCurrentComment();
                //                var json_strng = JSON.stringify(odata)
                //window.alert($.parseJSON(odata));
                var buttonName = $(this).val();
                $.ajax({
                    url: 'AdminService.svc/ReCreateDbSchema',
                    type: 'POST',
                    contentType: 'application/json',
                    dataType: 'text',
                    data: "",
                    processData: true,
                    isLocal: true,
                    beforeSend: function () {
                        $(this).val("Executing...").attr("disabled", "disabled")
                    },
                    complete: function () {
                        $(this).val(buttonName).removeAttr("disabled");
                    },
                    success: function (result) {
                        //window.alert(result);
                        $("#msg").html(result);
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        window.alert("ajax call fail");
                    }
                });
            });

            $("#btnInsertData").click(function () {
                //                var odata = GetCurrentComment();
                //                var json_strng = JSON.stringify(odata)
                //window.alert($.parseJSON(odata));
                var buttonName = $(this).val();
                $.ajax({
                    url: 'AdminService.svc/InitDbData',
                    type: 'POST',
                    contentType: 'application/json',
                    dataType: 'text',
                    data: "",
                    processData: true,
                    isLocal: true,
                    beforeSend: function () {
                        $(this).val("Executing...").attr("disabled", "disabled")
                    },
                    complete: function () {
                        $(this).val(buttonName).removeAttr("disabled");
                    },
                    success: function (result) {
                        //window.alert(result);
                        $("#msg").html(result);
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        window.alert("ajax call fail");
                    }
                });
            });
        });
    </script>
</asp:Content>
